#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


Exercise 1.4.12 - Write a code fragment to print the transposition (rows
and columns changed) of a square two-dimensional array. For the example
spreadsheet array in the text, you code would print the following:

99 98 92 94 99 90 76 92 97 89
85 57 77 32 34 46 59 66 71 29
98 78 76 11 22 54 88 89 24 38

Syntax:
python transposition.py

'''

def main():
    ''' Transpose the provided two-dimensional array '''

    grades = [[99, 85, 98], [98, 57, 78], [92, 77, 76],
              [94, 32, 11], [99, 34, 22], [90, 46, 54],
              [76, 59, 88], [92, 66, 89], [97, 71, 24],
              [89, 29, 38]]

    for _ in grades:
        print _
    print

    transposed = [[0 for _ in range(10)] for _ in range(3)]

    for col in range(3):
        for row in range(10):
            transposed[col][row] = grades[row][col]

    for _ in transposed:
        print _

if __name__ == '__main__':
    main()
